<tpl> include file='sys_config.head.html' </tpl>
<div id="doc3">
	<div id="yui-main">
		<div class="yui-g">
 			<div id="divinbox">
				<div class="gtlbar">
					<div class="gtlbar-left">预立项管理 &gt;&gt; 分配人员表</div>
					<!--<div onclick="location.href='distribute_member.manage.php?action=view'" class="gtlbar-right">
							<input type="button" name="" class="apd" style="width:150px;">
							<b>浏览&打印&审批</b>
					</div>-->
				</div>
				<div class="ctge">
					<div class="ctge-1">
						<div style="font-size:16px; font-weight:bold; height:30px;">
	    					<a href="project_official.manage.php?action=view&id=<tpl> $project_array.id </tpl>&curpage=<tpl> $curpage </tpl>"><tpl> $project_array.project_name </tpl></a>
	    				</div>
						<form action="distribute_member.manage.php?action=save" method="post" id="form1" onsubmit="return submitForm()" >
						<input type="hidden" name="project_id" value="<tpl> $project_array.id </tpl>" >
        				<div class="ctge-1-1">
						<table cellSpacing="0" cellPadding="0" class="fct" border="0">
							<tr>
								<th>部门:</th>
								<td colspan="3"><select name="dept_id" onchange="showMembers(this.value)">
								<option value="">--请选择--</option>
								<tpl> section name=loop loop=$dept_array </tpl>
                                       <option value="<tpl> $dept_array[loop].id </tpl>"><tpl> $dept_array[loop].name </tpl></option>
                                <tpl> /section </tpl>
								</select></td>
						     </tr>
						     <tr>
                                <th>公司员工：</th>
                                <td style="width:100px;">
                                   	<select name="memberlist1" multiple style="width:150px;height:150px;" id="memberlist1"/>
                                   	</select>
                                </td>
                                <td style="width:50px; text-align: center;">
                                	<br><br>
                                	<input type="button" value="<<" class="bthl" onclick="left()">
                                	<br><br>
									<input type="button" value=">>" class="bthl" onclick="right()">
                                </td>
                                <td>
                                   	<select name="memberlist2[]" multiple style="width:150px;height:150px;" id="memberlist2"/>
                                   	</select>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="4" style="text-align:center;">
                                    <input type="submit" name="add_time" class="bthl" value="增加" " />&nbsp;&nbsp;
                                    <input type="button" name="del_time" class="bthl" value="删除"  />
                                </td>
                            </tr>
						</table>
						</form>
						<br>
						<form id="delform" action="distribute_member.manage.php" method="POST">
						<input type="hidden" name="action" value="update">
						<input type="hidden" name="project_id" value="<tpl> $project_array.id </tpl>">
                   		<table cellSpacing="0" cellPadding="0" class="fct" border="0">
							<tr>
					         	<td colspan="6" style="height:30px; font-size:14px; font-weight:bold;">分配工作时间及工作权重</td>
						    </tr>    
							<tr style="background-color:#eee">
								<td style="text-align:center; font-size:14px;">
								   选择
								</td>
								<td style="text-align:center; font-size:14px;">
								   姓名
								</td>
								<td style="text-align:center; font-size:14px;">
								   部门
								</td>
								<td style="text-align:center; font-size:14px;">
								   工作时间段
								</td>
								<td style="text-align:center; font-size:14px;">
								   工量权重
								</td>
								<td style="text-align:center; font-size:14px;">
								   分配角色
								</td>
						    </tr>
						    <tpl> section name=loop loop=$member_array </tpl>
							<tr>
								<td style="text-align:center; ">
									<input type="checkbox" name="id" value="<tpl> $member_array[loop].id </tpl>">
									<input type="hidden" name="member_id[]" value="<tpl> $member_array[loop].id </tpl>" />
								</td>
								<td style="text-align:center; ">
									<tpl> $member_array[loop].member_name </tpl>
								</td>
								<td style="text-align:center; ">
									<tpl> $member_array[loop].dept_name </tpl>
								</td>
								<td style="text-align:center; ">
									<input class="fct-input" readonly name="start_date[]" id="start_date<tpl> $member_array[loop].id </tpl>" value="<tpl> $member_array[loop].start_date </tpl>" style="width:100px;" /> - <input class="fct-input" readonly name="end_date[]" id="end_date<tpl> $member_array[loop].id </tpl>" value="<tpl> $member_array[loop].end_date </tpl>" style="width:100px;"/>
								</td>
								<td style="text-align:center; ">
									<input class="fct-input" name="scale[]" id="scale<tpl> $member_array[loop].id </tpl>"  value="<tpl> $member_array[loop].scale </tpl>" style="width:100px;"/>%
								</td>
								<td style="text-align:center; ">
									<select name="role_id[]" id="role_id<tpl> $member_array[loop].id </tpl>" >
								    	<option value="1" <tpl> $project_array[loop].id </tpl> >项目经理</option>
								       	<option value="2">产品经理</option>
								       	<option value="3">项目总监</option>
								   	</select>
								</td>
							</tr>
							<tpl> /section </tpl>
                            <tr>
                                <td colspan="6" style="text-align:center;">
                                    <input type="submit" name="del_time" class="bthl" value="提交"  />
                                </td>
                            </tr>
						</table>
						</form>
						</div>
					</div>
				</div>	
			</div>
		</div>
	</div>
</div>
<tpl> include file='sys_config.js.html' </tpl>
<link href="<tpl> $site_url </tpl>/js/jquery/ui.theme.css" rel="stylesheet" type="text/css" />
<script src="<tpl> $site_url </tpl>/js/jquery/ui.datepicker.js"></script>

<script>
$(document).ready(function(){
<tpl> section name=loop loop=$member_array </tpl>
	$('#start_date<tpl> $member_array[loop].id </tpl>').datepicker({
		dateFormat:'yy-mm-dd',
		changeMonth: true,
		changeYear: true
	});
	$('#end_date<tpl> $member_array[loop].id </tpl>').datepicker({
		dateFormat:'yy-mm-dd',
		changeMonth: true,
		changeYear: true
	});
<tpl> /section </tpl>
});

function submitForm(){
	selectedAll();
	return true;
}
function showMembers(dept_id){
	$('#memberlist1').html('');
	if(dept_id != ''){
		$.getJSON('member.manage.php?action=ajaxmembersbydept&dept_id='+dept_id, function(data){
			$.each(data, function(k, v) {
	            $('#memberlist1').append('<option value="'+(v.member_id)+'">'+(v.real_name)+'</option>');
	        });
		});
	}
}
function right(){
	l = document.getElementById("memberlist1");
	r = document.getElementById("memberlist2");
	for(i=0;i<l.options.length;i++){
		if(l.options[i].selected){
			ot = l.options[i].text;
			ov = l.options[i].value;
			r.options[r.options.length] = new Option(ot,ov);
			//l.options[i] = null;
		}
	}
}
function left(){
	r = document.getElementById("memberlist2");
	for(i=0;i<r.options.length;i++){
		if(r.options[i].selected){
			r.options[i] = null;
		}
	}
}
function selectedAll(){
	r = document.getElementById("memberlist2");
	for(i=0;i<r.options.length;i++){
		r.options[i].selected = true;
	}
}
</script>
</body>
</html>